home *** CD-ROM | disk | FTP | other *** search
- '--------------------------------------------------------------------------
- ' EnumFiles.vbs - Enumerates files from the system directory and prints
- ' version information for files that have it.
- '
- ' This file is part of the sgVersionInfo.
- ' Copyright (C) 1998 Stinga
- ' All rights reserved.
- '
- ' This source code demonstrates usage of the sgVersionInfo component
- ' and it's string properties.
- '--------------------------------------------------------------------------
-
- ' sgFileFlag constants
- const sgVS_FF_DEBUG = &H00000001
- const sgVS_FF_PRERELEASE = &H00000002
- const sgVS_FF_PATCHED = &H00000004
- const sgVS_FF_PRIVATEBUILD = &H00000008
- const sgVS_FF_INFOINFERRED = &H00000010
- const sgVS_FF_SPECIALBUILD = &H00000020
-
- ' sgFileOS constants
- const sgVOS_UNKNOWN = &H00000000
- const sgVOS_DOS = &H00010000
- const sgVOS_OS216 = &H00020000
- const sgVOS_OS232 = &H00030000
- const sgVOS_NT = &H00040000
- const sgVOS__BASE = &H00000000
- const sgVOS__WINDOWS16 = &H00000001
- const sgVOS__PM16 = &H00000002
- const sgVOS__PM32 = &H00000003
- const sgVOS__WINDOWS32 = &H00000004
- const sgVOS_DOS_WINDOWS16 = &H00010001
- const sgVOS_DOS_WINDOWS32 = &H00010004
- const sgVOS_OS216_PM16 = &H00020002
- const sgVOS_OS232_PM32 = &H00030003
- const sgVOS_NT_WINDOWS32 = &H00040004
-
- ' sgFileType constants
- const sgVFT_UNKNOWN = &H00000000
- const sgVFT_APP = &H00000001
- const sgVFT_DLL = &H00000002
- const sgVFT_DRV = &H00000003
- const sgVFT_FONT = &H00000004
- const sgVFT_VXD = &H00000005
- const sgVFT_STATIC_LIB = &H00000007
-
- ' sgFileSubtype constants
- const sgVFT2_UNKNOWN = &H00000000
- const sgVFT2_DRV_PRINTER = &H00000001
- const sgVFT2_DRV_KEYBOARD = &H00000002
- const sgVFT2_DRV_LANGUAGE = &H00000003
- const sgVFT2_DRV_DISPLAY = &H00000004
- const sgVFT2_DRV_MOUSE = &H00000005
- const sgVFT2_DRV_NETWORK = &H00000006
- const sgVFT2_DRV_SYSTEM = &H00000007
- const sgVFT2_DRV_INSTALLABLE = &H00000008
- const sgVFT2_DRV_SOUND = &H00000009
- const sgVFT2_DRV_COMM = &H0000000A
- const sgVFT2_DRV_INPUTMETHOD = &H0000000B
- const sgVFT2_FONT_RASTER = &H00000001
- const sgVFT2_FONT_VECTOR = &H00000002
- const sgVFT2_FONT_TRUETYPE = &H00000003
-
- ' Create some objects
- set VerInfo = WScript.CreateObject("sgVersionInfo.VersionInfo")
- Set fs = WScript.CreateObject("Scripting.FileSystemObject")
- Set foldr = fs.GetFolder(WScript.Path)
-
- On Error Resume Next
- Dim sMsg
- Dim vbCrLf
- vbCrLf = Chr(13) + Chr(10)
-
- ' Are we running from command line
- Dim bFromCmdLine
- bFromCmdLine = false
- if InStrRev(UCase(WScript.FullName), "CSCRIPT") then bFromCmdLine = true
-
- ' Scan all files in the folder
- For Each File In foldr.Files
-
- Err.Number = 0
- sMsg = ""
-
- ' Try to get version info for current file
- VerInfo.Path = File.Path
- if Err.Number = 0 then
- ' No error. Display version info if file contains any
- if VerInfo.InfoExist then
- sMsg = UCase(file.Name) + " - " + VerInfo.FileDescription + vbCrLf
- sMsg = sMsg + "Product Name: " + VerInfo.ProductName + vbCrLf
- sMsg = sMsg + "File Version: " + VerInfo.FileVersion + vbCrLf
- sMsg = sMsg + "Product Version: " + VerInfo.ProductVersion + vbCrLf
- sMsg = sMsg + "Company Name: " + VerInfo.CompanyName + vbCrLf
- sMsg = sMsg + "Internal Name: " + VerInfo.InternalName + vbCrLf
- sMsg = sMsg + "Original Filename: " + VerInfo.OriginalFilename + vbCrLf
- sMsg = sMsg + "Private Build: " + VerInfo.PrivateBuild + vbCrLf
- sMsg = sMsg + "Special Build: " + VerInfo.SpecialBuild + vbCrLf
- sMsg = sMsg + "Legal Copyright: " + VerInfo.LegalCopyright + vbCrLf
- sMsg = sMsg + "Legal Trademarks: " + VerInfo.GetValue("StringFileInfo", "LegalTrademarks") + vbCrLf
- sMsg = sMsg + "Language: " + VerInfo.LanguageName + vbCrLf
- sMsg = sMsg + "Comments: " + VerInfo.Comments + vbCrLf
- sMsg = sMsg + "OS: " + VerInfo.FileOSString + vbCrLf
-
- if bFromCmdLine then
- WScript.Echo sMsg
- else
- rc = MsgBox(sMsg, 1)
- if rc = 2 then WScript.Quit(0)
- end if
- end if
- else
- ' An error occured or file does not have version info
- sMsg = File.Path & ": " & vbCrLF & _
- Err.Description & vbCrLf & _
- "Error #:" & CStr(Err.Number)
- if bFromCmdLine then
- WScript.Echo sMsg
- else
- MsgBox sMsg
- end if
- end if
- next
-
- MsgBox "Finished"
-
- set VerInfo = nothing
- Set fs = nothing
- Set foldr = nothing
-